<?php

/**
 * descript:
 * User: blue
 * Date: 2018/9/17 16:51
 */

namespace app\api\model;

use app\library\base\BaseModel;
use think\Db;

class Group extends BaseModel
{
    protected $name='auth_group';
    protected $insertFields=['title','status','rules'];
    protected $updateFields=['id','title','status','rules'];

    public function user(){
        return $this->belongsToMany('User','auth_group_access','uid','group_id');
    }

    //删除组表时,删除中间表的数据
    protected function after_delete($ids){
        $res=Db::table('think_auth_group_access')->whereIn('group_id',$ids)->delete();
    }

}